﻿using System.Drawing;

namespace GDI
{
    public class Pie : PrintableItem
    {
        private Pen f_Pen;
        private Brush f_Brush;
        private RectangleF f_Rect;
        private float f_StartAngle;
        private float f_Angle;

        public Pie(RectangleF Rect, float StartAngle = 0, float Angle = 360, Pen pen = null, Brush brush = null)
        {
            f_Rect = Rect;
            f_StartAngle = StartAngle;
            f_Angle = Angle;
            f_Pen = pen;
            f_Brush = brush;
        }

        #region Overrides of PrintableItem

        /// <summary>Метод отрисовки</summary>
        /// <param name="g">Графический контент</param>
        protected override void Draw(Graphics g)
        {
            var x = f_Rect.X;
            var y = f_Rect.Y;
            var width = f_Rect.Width;
            var height = f_Rect.Height;

            if(f_Pen != null)
                g.DrawPie(f_Pen, f_Rect, f_StartAngle, f_Angle);
            if(f_Brush != null)
                g.FillPie(f_Brush, x, y, width, height, f_StartAngle, f_Angle);
        }

        #endregion
    }
}
